<?php

/**
 * Class for viewing a textarea element.
 *
 * @author Ian Clarence <ian.clarence@gmail.com>
 */
class ViewTextArea extends ViewHtmlFormElement {

    /**
     * Flag indicating whether there is any whitespace in the inner HTML.
     */
    const NO_WHITESPACE = TRUE;

    /**
     * Default number of columns.
     */
    const DEFAULT_COLUMNS = 40;

    /**
     * Default number of rows.
     */
    const DEFAULT_ROWS = 5;

    /**
     * The constructor.
     *
     * @param array $fields
     */
    public function __construct(array $fields = array()) {

        $fields["tag"] = "textarea";
        $fields["columns"] = isset($fields["columns"]) ? $fields["columns"] : self::DEFAULT_COLUMNS;
        $fields["rows"] = isset($fields["rows"]) ? $fields["rows"] : self::DEFAULT_ROWS;

        parent::__construct($fields);
        
        $this->value = $this->value == NULL ? "" : $this->value;
        $this->addText($this->value);
        $this->setAttribute("cols", $this->getColumns());
        $this->setAttribute("rows", $this->getRows());
        
    }

}